package player.ui.video;

import java.awt.Component;
import java.awt.Point;
import java.awt.Window;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

import player.PS;


public class FrameDrag {
	Window window ;
	Component cp;
	boolean startDrag=false;   
	Point startFrameLocation=null;
	Point p;
	FrameDrag(final Window window ,Component cp){
		this.window=window;
		this.cp=cp;
		cp.addMouseMotionListener(new MouseMotionListener(){
			public void mouseDragged(MouseEvent e) {
				if(e.getModifiers()==16){
					if(startDrag){
						Point p1=e.getPoint();
						Point p2=window.getLocation(null);
						p2.x+=p1.x-p.x;
						p2.y+=p1.y-p.y;
						window.setLocation(p2);
					}
				}
			}

			public void mouseMoved(MouseEvent e) {}
		});

		cp.addMouseListener(new MouseListener(){

			public void mouseClicked(MouseEvent e) {}

			public void mouseEntered(MouseEvent e) {}

			public void mouseExited(MouseEvent arg0) {}

			public void mousePressed(MouseEvent e) {
				if(PS.videoFrame.isFullSereen){
					return;
				}
				startDrag=true;
				p= e.getPoint(); 
			}

			public void mouseReleased(MouseEvent arg0) {
				startDrag=false;
			}

		});
	}
}
